package it.nesimuge.score.gui;

import it.lapomuge.gui.JDialogImportaGiudici;
import it.nesimuge.score.gui.gare.JDialogGaraSingola;
import it.nesimuge.score.gui.gare.JDialogListaGare;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

public class JMainFrame extends JFrame {

	private JPanel contentPane;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					JMainFrame frame = new JMainFrame();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public JMainFrame() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 867, 300);
		
		JMenuBar menuBar = new JMenuBar();
		setJMenuBar(menuBar);
		
		JMenu mnGare = new JMenu("Gare");
		menuBar.add(mnGare);
		
		JMenuItem jMenuGaraNuova = new JMenuItem("Nuova");
		jMenuGaraNuova.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				nuovaGara();
				
			}
			@Override
			public void mousePressed(MouseEvent e) {
				nuovaGara();
			}
		});
		mnGare.add(jMenuGaraNuova);
		
		JMenuItem jMenuGaraModifica = new JMenuItem("Modifica");
		jMenuGaraModifica.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				listaGare();
			}
			@Override
			public void mousePressed(MouseEvent e) {
				listaGare();
			}
		});
		mnGare.add(jMenuGaraModifica);
		
		JMenuItem jMenuGaraSeleziona = new JMenuItem("Seleziona");
		mnGare.add(jMenuGaraSeleziona);
		
		JMenu mnAtleti = new JMenu("Atleti");
		menuBar.add(mnAtleti);
		
		JMenuItem jMenuAtletiNuovo = new JMenuItem("Nuovo");
		mnAtleti.add(jMenuAtletiNuovo);
		
		JMenuItem jMenuAtletiModifica = new JMenuItem("Modifica");
		mnAtleti.add(jMenuAtletiModifica);
		
		JMenuItem mntmImporta = new JMenuItem("Importa");
		mntmImporta.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				importaAtleti();
			}
			@Override
			public void mousePressed(MouseEvent e) {
				importaAtleti();
			}
		});
		mnAtleti.add(mntmImporta);
		
		JMenu mmGiudici = new JMenu("Giudici");
		menuBar.add(mmGiudici);
		
		JMenuItem jMenuGiudiciNuovo = new JMenuItem("Nuovo");
		mmGiudici.add(jMenuGiudiciNuovo);
		
		JMenuItem jMenuGiudiciModifica = new JMenuItem("Modifica");
		mmGiudici.add(jMenuGiudiciModifica);
		
		JMenuItem mntmImporta_1 = new JMenuItem("Importa");
		mntmImporta_1.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				importaGiudici();
			}

			
			@Override
			public void mousePressed(MouseEvent arg0) {
				importaGiudici();
			}
		});
		mmGiudici.add(mntmImporta_1);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
	}

	protected void nuovaGara() {
		JDialogGaraSingola g = new JDialogGaraSingola();
		g.setVisible(true);		
	}

	protected void listaGare() {
		JDialogListaGare g = new JDialogListaGare();
		g.setVisible(true);
		
	}

	protected void importaAtleti() {
		 JDialogImportaAtleti a = new JDialogImportaAtleti();
		 a.setVisible(true);
		
	}
	
	private void importaGiudici() {
		 JDialogImportaGiudici a = new JDialogImportaGiudici();
		 a.setVisible(true);		
	}

}
